home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / archive / userbox / publicdomain / frexxed.lha / frexxed / bin / startfred.c < prev    next >
C/C++ Source or Header  |  1995-01-09  |  4KB  |  141 lines

  1. /*********************************************************************
  2.  *
  3.  * $Source: Avocado:Work/Data/Source/Project/Misc/RCS/StartFred.c $
  4.  * $Revision: 1.3 $
  5.  * $Date: 1995/01/06 16:45:02 $
  6.  * $Author: Mikael_Saker $
  7.  * ------------------------------------------------------------------
  8.  * $Log: StartFred.c $
  9.  * Revision 1.3  1995/01/06  16:45:02  Mikael_Saker
  10.  * Added real argument-handling. Changed printf() to internal Printf() to
  11.  * disable stdio and gain about 4kB...
  12.  *
  13.  * Revision 1.2  1995/01/03  18:48:04  Mikael_Saker
  14.  * Handles 'sticky' and safer WB-starts.
  15.  *
  16.  * Revision 1.1  1994/12/15  23:17:17  Mikael_Saker
  17.  * Klarar Massa filer och Shell...
  18.  *
  19.  * Revision 1.0  1994/12/13  23:57:48  Mikael_Saker
  20.  * Initial revision
  21.  *
  22.  * ------------------------------------------------------------------
  23.  *            Copyright (c) 1994,1995, Mikael Saker
  24.  * ------------------------------------------------------------------
  25.  *
  26.  *********************************************************************/
  27.  
  28. /* Program slightly enhanced and fixed by Daniel Stenberg */
  29.  
  30. #include <proto/all.h>
  31. #include <stdio.h>
  32. #include <string.h>
  33.  
  34. // ------------------------------------------------------------------
  35.  
  36. // %%% MakeVerTags RevInfo
  37. #define PROGNAME    "StartFred"
  38. #define VERSION            1
  39. #define REVISION        3
  40. #define BUMPREV            -1
  41. #define DATE        "06.01.95"
  42. #define VERS        "StartFred 1.3"
  43. #define VSTRING        "StartFred 1.3 (06.01.95)"
  44. #define VERSTAG        "\0$" "VER: StartFred 1.3 (06.01.95)"
  45. // %%% MakeVerTags RevInfo
  46.  
  47. #define    TEMPLATE    "Files/A/M,Sticky/S"
  48. #define    AFILES            0
  49. #define    ASTICKY            1
  50. #define    ANUMARGS        2
  51.  
  52. char    ver[] = VERSTAG;
  53. void    main(LONG argc, UBYTE **argv);
  54.  
  55. // ------------------------------------------------------------------
  56.  
  57. void main(LONG argc, UBYTE **argv)
  58. {
  59.   UBYTE  command[256],
  60.   **filelist,
  61.   argpath[128],
  62.   path[128],
  63.   temp[128],
  64.   sticky = 0;
  65.   struct WBStartup *wbs;
  66.   struct RDArgs *args;
  67.   LONG  arglist[ANUMARGS];
  68.   ULONG argcount;
  69.  
  70.   if(argc == 0)
  71.   {
  72.     /*    started from WB... */
  73.  
  74.     wbs = (struct WBStartup *) argv; //    Startup Msg
  75.     if(wbs->sm_NumArgs >= 1)
  76.     {
  77.       if(wbs->sm_NumArgs == 1)
  78.         SystemTagList("Sys:Rexxc/rx FrexxEd:Rexx/FrexxEdStart.rx", NULL);
  79.       for(argcount = 1;argcount < wbs->sm_NumArgs;argcount++)
  80.       {
  81.         strcpy(command, "Sys:Rexxc/rx FrexxEd:Rexx/FrexxEdStart.rx \"");
  82.         if(NameFromLock(wbs->sm_ArgList[argcount].wa_Lock, path, 128))
  83.         {
  84.           strmfp(temp, path, wbs->sm_ArgList[argcount].wa_Name);
  85.           strcat(command, temp);
  86.           strcat(command, "\"");
  87.           SystemTagList(command, NULL);
  88.         }
  89.       }
  90.     }
  91.   }
  92.   else if(argc>1)
  93.   {
  94.     //    Started from shell
  95.  
  96.     arglist[ASTICKY] = FALSE;
  97.     arglist[AFILES] = NULL;
  98.     args = ReadArgs(TEMPLATE, arglist, NULL);
  99.     if(args == NULL)
  100.       return;
  101.  
  102.     if(arglist[ASTICKY])
  103.       sticky = TRUE;
  104.  
  105.     filelist = (UBYTE **) arglist[AFILES];
  106.  
  107.     if(GetCurrentDirName(path, 128))    // Get current directory path...
  108.     {
  109.       for(argcount = 0;filelist[argcount] != NULL;argcount++)
  110.       {
  111.         strcpy(command, "Sys:Rexxc/rx FrexxEd:Rexx/FrexxEdStart.rx \"");
  112.         stcgfp(argpath, filelist[argcount]);
  113.         strmfp(temp, path, filelist[argcount]);
  114.  
  115.         if(strchr(argpath, ':'))
  116.         {
  117.           //  If the file name contains a ':', use the full path name and
  118.           //  not the one from GetCurrentDirName()...
  119.           //  FrexxEdStart.rx *HAVE TO* get the full path specified!
  120.           
  121.           strcat(command, filelist[argcount]);
  122.         }
  123.         else
  124.           strcat(command, temp);
  125.         strcat(command, "\"");
  126.  
  127.         if(sticky)
  128.           strcat(command, " STICKY");
  129.         
  130.         SystemTagList(command, NULL);
  131.       }
  132.     }
  133.     FreeArgs(args);
  134.   }
  135.   else
  136.   {
  137.     Printf("%s [files] [STICKY]\n"
  138.            "Loads all the specified files into FrexxEd\n", argv[0]);
  139.   }
  140. }
  141.